Feature: Quote API - Census Validation

  @sad
  Scenario Outline: Zip Code and County Validation
    When I send a POST request to Quote API "quote/ifp"
      """
      { 
      "zipCode": <zipcode>,
      "county": <county>,
      "forcedOep": false,
      "allianceId": "Gro21010",
      "members": {
      "primary": {
        "gender": "MALE",
        "birthday": "11/11/1980",
        "smoker": true,
        "student": false
      }
      }
      }
      """
    Then the response status should be <status>
    And the error message should be "<message>"

    Examples: Zipcode invalid
      | zipcode | county | status | message                   |
      | null    | "KING" | 400    | Parameter zipCode is null |
      | "11111" | "KING" | 400    | zipCode is invalid: 11111 |
      | "aaass" | "KING" | 400    | zipCode is invalid: aaass |

    Examples: County invalid
      | zipcode | county | status | message                 |
      | "44444" | null   | 400    | county is missing.      |
      | "44444" | "KING" | 400    | county is invalid: KING |

  @sad
  Scenario Outline: Request Effective Date, QLE, QLE date Validation
    When I send a POST request to "quote/ifp"
      """
      { 
      "zipCode": "98001",
      "county": "KING",
      "requestEffectiveDate": <requestEffectiveDate>,
      "qualifyingLifeEvent": <qualifyingLifeEvent>,
      "forcedOep": false,
      "allianceId": "Gro21010",
      "dateOfEvent": <dateOfEvent>,
      "members": {
      "primary": {
        "gender": "MALE",
        "birthday": "11/11/1980",
        "smoker": true,
        "student": false
      }
      }
      }
      """
    Then the response status should be 400
    And the error message should be "<message>"

    Examples: Invalid request effective date
      | requestEffectiveDate | qualifyingLifeEvent | dateOfEvent  | message                                                                     |
      | "2016/06/01"         | "LOSS_OF_COVERAGE"  | "07/09/2016" | Invalid requestEffectiveDate. Date=2016/06/01, accepted format: MM/dd/yyyy. |
      | null                 | "LOSS_OF_COVERAGE"  | "07/09/2016" | effectiveDate is invalid                                                    |

    Examples: Invalid QLE
      | requestEffectiveDate | qualifyingLifeEvent | dateOfEvent  | message                                                        |
      | "06/01/2016"         | "LOSS OF COVERAGE"  | "07/09/2016" | Unsupported qualifyingLifeEvent value, value =LOSS OF COVERAGE |
      | "06/01/2016"         | null                | "07/09/2016" | qle is invalid: null                                           |

    Examples: Invalid date of event
      | requestEffectiveDate | qualifyingLifeEvent | dateOfEvent  | message                                                            |
      | "06/01/2016"         | "LOSS_OF_COVERAGE"  | "2016/05/09" | Invalid dateOfEvent. Date=2016/05/09, accepted format: MM/dd/yyyy. |
      | "06/01/2016"         | "LOSS_OF_COVERAGE"  | null         | qle or doe is invalid! qle: coverage, doe: null                    |

  @happy
  Scenario: During OEP, QLE and date can be null
    When I send a POST request to "quote/ifp"
      """
      { 
      "zipCode": "98001",
      "county": "KING",
      "qualifyingLifeEvent": null,
      "dateOfEvent":null,
      "requestEffectiveDate":"06/01/2016",
      "forcedOep": true,
      "allianceId": "Gro21010",
      "dateOfEvent": null,
      "members": {
      "primary": {
        "gender": "MALE",
        "birthday": "11/11/1980",
        "smoker": true,
        "student": false
      }
      }
      }
      """
    Then the response status should be 200

  @sad
  Scenario: Alliance Id Validation
    When I send a POST request to Quote API "quote/ifp"
      """
      {
      "zipCode": "98001",
      "county": "KING",
      "forcedOep": false,
      "allianceId": "jet900000",
      "members": {
      "primary": {
        "gender": "MALE",
        "birthday": "11/11/1980",
        "smoker": true,
        "student": false
      }
      }
      }
      """
    Then the response status should be 400
    And the error message should be "Not supported allianceId: jet900000."

  @sad
  Scenario Outline: Primary Gender,DOB,Smoker,Student Validation
    When I send a POST request to Quote API "quote/ifp"
      """
      {
      "zipCode": "98001",
      "county": "KING",
      "forcedOep": true,
      "allianceId": "Gro21010",
      "members": {
      "primary": {
      "gender": <gender>,
      "birthday": <dob>,
      "smoker": true,
      "student": false
      }
      }
      }
      """
    Then the response status should be 400
    And the error message should be "<message>"

    Examples: 
      #Gender validation
      | gender | dob          | smoker | student | message                                                         |
      | null   | "11/11/1980" | true   | true    | Parameter gender is null                                        |
      | "girl" | "11/11/1980" | true   | true    | Unsupported gender value, value =girl                           |
      #dob validation
      | "MALE" | "1980/11/11" | true   | true    | Invalid birthday. Date=1980/11/11, accepted format: MM/dd/yyyy. |
      | "MALE" | null         | true   | true    | Parameter birthday is null                                      |
      | "MALE" | "01/02/1800" | true   | true    | primary age is invalid: 216                                     |

  @sad
  Scenario Outline: Spouse Gender,DOB,Smoker,Student Validation
    When I send a POST request to Quote API "quote/ifp"
      """
      {
      "zipCode": "98001",
      "county": "KING",
      "allianceId": "Gro21010",
      "members": {
      "primary": {
      "gender": "Female",
      "birthday": "01/02/1980",
      "smoker": true,
      "student": false
      },
      "secondary": {
      "gender": <gender>,
      "birthday": <dob>,
      "smoker": false,
      "student": false
      }
      }
      }
      """
    Then the response status should be 400
    And the error message should be "<message>"

    Examples: 
      #Gender validation
      | gender  | dob          | smoker | student | message                                                         |
      | null    | "11/11/1980" | true   | true    | Parameter gender is null                                        |
      | "girl"  | "11/11/1980" | true   | true    | Unsupported gender value, value =girl                           |
      #dob validation
      | "MALE"  | "1980/11/11" | true   | true    | Invalid birthday. Date=1980/11/11, accepted format: MM/dd/yyyy. |
      | "MALE"  | null         | true   | true    | Parameter birthday is null                                      |
      | "MALE " | "01/02/1800" | true   | true    | secondary age is invalid: 216                                   |
      | "MALE"  | "01/02/2003" | true   | true    | secondary age is invalid: 13                                    |

  @sad
  Scenario Outline: Child Gender,DOB,Smoker,Student Validation
    When I send a POST request to Quote API "quote/ifp"
      """
      {
      "zipCode": "98001",
      "county": "KING",
      "forcedOep": true,
      "allianceId": "Gro21010",
      "members": {
      "primary": {
      "gender": "Female",
      "birthday": "01/02/1980",
      "smoker": true,
      "student": false
      },
      "secondary": {
      "gender": "Female",
      "birthday": "01/02/1980",
      "smoker": false,
      "student": false
      },
      "children": [{
      "gender": <gender>,
      "birthday": <dob>,
      "smoker": false,
      "student": false
      }
      ]
      }
      }
      """
    Then the response status should be 400
    And the error message should be "<message>"

    Examples: 
      #Gender validation
      | gender | dob          | smoker | student | message                                                         |
      | null   | "11/11/1980" | true   | true    | Parameter gender is null                                        |
      | "girl" | "11/11/1980" | true   | true    | Unsupported gender value, value =girl                           |
      #dob validation
      | "MALE" | "2000/01/02" | true   | true    | Invalid birthday. Date=2000/01/02, accepted format: MM/dd/yyyy. |
      | "MALE" | "01/02/1980" | true   | true    | child age is invalid: 36                                        |
      | "MALE" | null         | true   | true    | Parameter birthday is null                                      |
      | "MALE" | "01/02/1800" | true   | true    | child age is invalid: 216                                       |
